package com.notices.controller;

import com.notices.pojo.Noticesview;
import com.notices.service.INoticesviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/noticesview")
public class NoticesviewController {
    @Autowired
    private INoticesviewService service;
    @GetMapping
    public List<Noticesview> list(){
        return service.list();
    }
    @GetMapping("/{id}")
    public Noticesview getInfo(@PathVariable Integer id) {
            return service.getById(id);
    }
    @PostMapping
    public Integer add(@RequestBody Noticesview noticesview){
        if (noticesview.getNoticeId()==null){
            return 0;
        }
        int rlt= service.add(noticesview);
        return rlt;
    }
    @PutMapping
    public Integer update(@RequestBody Noticesview noticesview){
        return service.update(noticesview);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return service.delete(id);
    }
}
